/*
 * The maRla Project - Graphical problem solver for statistical calculations.
 * Copyright © 2011 Cedarville University
 * http://marla.googlecode.com
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful,Processor
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

package marla.ide.gui;

import java.awt.Cursor;
import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
import javax.swing.ImageIcon;
import javax.swing.JFrame;

/**
 * The About dialog.
 *
 * @author Alex Laird
 */
public class AboutDialog extends EscapeDialog
{
    /**
     * Construct the About dialog.
     *
	 * @param parent The contained to set as the parent.
     * @param viewPanel A reference to the view panel.
     */
    public AboutDialog(JFrame parent, ViewPanel viewPanel)
    {
		super (parent, viewPanel);

		initComponents ();
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings ("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        aboutJPanel = new javax.swing.JPanel();
        hyperlinkLabel1 = new javax.swing.JLabel();
        aboutLicense = new javax.swing.JLabel();
        aboutLabel = new javax.swing.JLabel();
        versionLabel = new javax.swing.JLabel();
        aboutLicense1 = new javax.swing.JLabel();
        jPanel1 = new javax.swing.JPanel();
        jButton1 = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setIconImage(new ImageIcon (getClass ().getResource (Domain.IMAGES_DIR + "logo.png")).getImage ());
        setResizable(false);

        hyperlinkLabel1.setFont(new java.awt.Font("Verdana", 0, 12)); // NOI18N
        hyperlinkLabel1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/marla/ide/images/logo.png"))); // NOI18N
        hyperlinkLabel1.setText("<html><a href=\"http://www.getorganizedapp.com\">marla.googlecode.com</a></html>");
        hyperlinkLabel1.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseEntered(java.awt.event.MouseEvent evt) {
                hyperlinkLabel1aboutPanelMouseEntered(evt);
            }
            public void mouseExited(java.awt.event.MouseEvent evt) {
                hyperlinkLabel1aboutPanelMouseExited(evt);
            }
            public void mouseReleased(java.awt.event.MouseEvent evt) {
                hyperlinkLabel1MouseReleased(evt);
            }
        });

        aboutLicense.setFont(new java.awt.Font("Verdana", 0, 12)); // NOI18N
        aboutLicense.setText("<html>The maRla Project is software from Cedarville University and is licensed under the GNU General Public License version 3. Copyright © 2011 Cedarville University. For more information, visit our website.</html>");

        aboutLabel.setFont(new java.awt.Font("Verdana", 1, 14)); // NOI18N
        aboutLabel.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        aboutLabel.setIcon(new javax.swing.ImageIcon(getClass().getResource("/marla/ide/images/full_logo.png"))); // NOI18N

        versionLabel.setFont(new java.awt.Font("Verdana", 0, 12)); // NOI18N
        versionLabel.setText("<html><b>Version:</b> " + Domain.VERSION + " " + Domain.PRE_RELEASE + "</html>");

        aboutLicense1.setFont(new java.awt.Font("Verdana", 0, 12)); // NOI18N
        aboutLicense1.setText("<html><b>Developed by:</b> Alex Laird, Ryan Morehart, and Andrew Sterling</html>");

        jButton1.setFont(new java.awt.Font("Verdana", 0, 12)); // NOI18N
        jButton1.setText("Close");
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });
        jPanel1.add(jButton1);

        javax.swing.GroupLayout aboutJPanelLayout = new javax.swing.GroupLayout(aboutJPanel);
        aboutJPanel.setLayout(aboutJPanelLayout);
        aboutJPanelLayout.setHorizontalGroup(
            aboutJPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, aboutJPanelLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(aboutJPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jPanel1, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 280, Short.MAX_VALUE)
                    .addComponent(aboutLabel, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 280, Short.MAX_VALUE)
                    .addComponent(versionLabel, javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(aboutLicense, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 280, Short.MAX_VALUE)
                    .addComponent(hyperlinkLabel1, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(aboutLicense1, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 280, Short.MAX_VALUE))
                .addContainerGap())
        );
        aboutJPanelLayout.setVerticalGroup(
            aboutJPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(aboutJPanelLayout.createSequentialGroup()
                .addGap(6, 6, 6)
                .addComponent(aboutLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 125, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(versionLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 16, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(aboutLicense, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(hyperlinkLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 35, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(aboutLicense1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(aboutJPanel, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(aboutJPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );

        java.awt.Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
        setBounds((screenSize.width-316)/2, (screenSize.height-408)/2, 316, 408);
    }// </editor-fold>//GEN-END:initComponents

    private void hyperlinkLabel1MouseReleased(java.awt.event.MouseEvent evt)//GEN-FIRST:event_hyperlinkLabel1MouseReleased
    {//GEN-HEADEREND:event_hyperlinkLabel1MouseReleased
        if (viewPanel.domain.desktop != null)
        {
            try
            {
                viewPanel.domain.desktop.browse (new URI ("http://marla.googlecode.com"));
            }
            catch (IOException ex)
            {
                Domain.logger.add (ex);
            }
            catch (URISyntaxException ex)
            {
                Domain.logger.add (ex);
            }
        }
}//GEN-LAST:event_hyperlinkLabel1MouseReleased

    private void hyperlinkLabel1aboutPanelMouseExited(java.awt.event.MouseEvent evt)//GEN-FIRST:event_hyperlinkLabel1aboutPanelMouseExited
    {//GEN-HEADEREND:event_hyperlinkLabel1aboutPanelMouseExited
        setCursor (Cursor.getDefaultCursor ());
}//GEN-LAST:event_hyperlinkLabel1aboutPanelMouseExited

    private void hyperlinkLabel1aboutPanelMouseEntered(java.awt.event.MouseEvent evt)//GEN-FIRST:event_hyperlinkLabel1aboutPanelMouseEntered
    {//GEN-HEADEREND:event_hyperlinkLabel1aboutPanelMouseEntered
        setCursor (Cursor.getPredefinedCursor (Cursor.HAND_CURSOR));
}//GEN-LAST:event_hyperlinkLabel1aboutPanelMouseEntered

	private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
		dispose();
	}//GEN-LAST:event_jButton1ActionPerformed

    // Variables declaration - do not modify//GEN-BEGIN:variables
    protected javax.swing.JPanel aboutJPanel;
    private javax.swing.JLabel aboutLabel;
    private javax.swing.JLabel aboutLicense;
    private javax.swing.JLabel aboutLicense1;
    private javax.swing.JLabel hyperlinkLabel1;
    private javax.swing.JButton jButton1;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JLabel versionLabel;
    // End of variables declaration//GEN-END:variables

    /**
     * Launch the About dialog.
     */
    public void goViewAbout()
    {
        setLocationRelativeTo (viewPanel);
        setVisible (true);
    }
}
